package com.everydayflash.jiglib.pong {
	import com.as3dmod.modifiers.Scale;	
	import com.as3dmod.ModifierStack;
	import com.as3dmod.plugins.pv3d.LibraryPv3d;
	
	import org.papervision3d.materials.BitmapMaterial;
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.objects.parsers.DAE;	
	/**
	 * @author bartekd
	 */
	public class Racket extends DAE {

		[Embed (source="assets/racket.dae",mimeType="application/octet-stream")]
		private var Model:Class;
		
		[Embed (source="assets/racket_material.png")]
		private var Texture:Class;
		private var mesh:DisplayObject3D;

		public function Racket() {
			super();
			load(new Model());
			mesh = getChildByName("Cylinder", true);
			mesh.geometry.flipFaces();
			mesh.material = new BitmapMaterial(new Texture().bitmapData);
			
			
			// Collada objects from Blender are tiny and need scling
			// While one would expect that something like this would work:
			
			// mesh.scale = 300;
			
			// it does not at all.
			// The Scale modifier sloves this problem. It scales each vertex of the mesh, 
			// and calling collapse "bakes" the transformation. 
			var stack:ModifierStack = new ModifierStack(new LibraryPv3d(), mesh);
			var sc:Scale = new Scale(300, 300, 300);	
			stack.addModifier(sc);
			stack.collapse();
		}	}
}
